package net.fornwall.eclipsecoder.csharpsupport;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;

import net.fornwall.eclipsecoder.util.AbstractLauncher;

/**
 * See emonics DotNetLaunchShortcut.java
 */
public class CSharpLauncher extends AbstractLauncher {

	private IFile file;

	/**
	 * @param file
	 *            the binary file to launch
	 */
	public CSharpLauncher(IFile file) {
		this.file = file;
	}

	@Override
	protected String getLauncherName() {
		return file.getName();
	}

	@Override
	protected String getLauncherTypeId() {
		return "org.emonic.debug.core.dotNetApplication";
	}

	@Override
	protected void setUpConfiguration(ILaunchConfigurationWorkingCopy config) throws Exception {
		config.setAttribute("org.emonic.debug.core.EXECUTABLE_NAME", file.getProjectRelativePath().toString());
		config.setAttribute("org.emonic.debug.core.PROJECT", file.getProject().getName());
		config.setAttribute("org.emonic.debug.core.FRAMEWORK_NAME", new InstanceScope()
				.getNode("org.emonic.debug.core").get("org.emonic.debug.core.defaultFrameworkInstall", null));
	}

}
